package com.jdkreader.annotation;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by 昭毅 on 2017-6-5.
 * 注解处理器类
 */
public class UserCaseTracker {

    public static void
    trackUserCases(List<Integer> userCases,Class<?> c1){

        //获取类的所有公开方法
        for(Method m :c1.getDeclaredMethods()){
            //获取注解对象
            UserCase uc=m.getAnnotation(UserCase.class);

            if( uc != null){
                System.out.println("找到的UserCase: "+uc.id()+
                            ",描述是:"+uc.description());
                //移除已经打印的元素
                userCases.remove(new Integer(uc.id()));
            }

        }

        for(int i:userCases){

            System.out.println("找不到第"+i+"个UserCase");
        }


    }


    public static void main(String[] args) {
        List<Integer> userCases=new ArrayList<Integer>();
        Collections.addAll(userCases,1,2,3);
        trackUserCases(userCases,AnnTest.class);
    }
}
